<template>
  <div class="swiper">
    <van-swipe :autoplay="3000" indicator-color="deeppink" loop :height="200">
      <template v-if="!isdetail">
        <van-swipe-item v-for="item in banners" :key="item.acm" @click="tobannerimg(item.link)">
          <img :src="item.image || item" alt="" @load="imgload" />
        </van-swipe-item>
      </template>
      <template v-else>
        <van-swipe-item v-for="item in banners" :key="item">
          <img :src="item" alt="" />
        </van-swipe-item>
      </template>
    </van-swipe>
  </div>
</template>

<script>
import { ref } from 'vue'
export default {
  // props: ['banners', 'isdetail'],
  props: {
    banners: {
      type: Array,
      default: () => []
    },
    isdetail: {
      type: Boolean,
      default: false
    }
  },
  setup(props, _) {
    const isload = ref(false)
    const tobannerimg = (link) => {
      location.href = link
    }
    const imgload = () => {
      if (!isload.value) {
        _.emit('imgload')
      }
      isload.value = true
    }
    return {
      tobannerimg,
      imgload
    }
  }
}
</script>

<style scoped>
.swiper img {
  width: 100%;
}
</style>
